package cn.xyinping.pay.service.impl;

import cn.xyinping.basic.service.impl.BasicServiceImpl;
import cn.xyinping.basic.util.LoginContextUtil;
import cn.xyinping.pay.domain.PayBill;
import cn.xyinping.pay.mapper.PayBillMapper;
import cn.xyinping.pay.service.IPayBillService;
import cn.xyinping.user.domain.Logininfo;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.math.BigDecimal;
import java.util.Date;
/**
 * @author 27266
 * @desrciption  支付表
 * @date 2021/11/9
 */
@Service
@Transactional
public class PayBillServiceImpl extends BasicServiceImpl<PayBill> implements IPayBillService {
    @Override
    public void save(
            Long businessKey,
            Integer businessType,
            String title,
            BigDecimal money,
            Integer payChannel,
            Long shopId,
            String shopName,
            String payNo) {
        PayBill bill = new PayBill();
        //业务KEY
        bill.setBusinessKey(businessKey);
        //通过工具类获取用户信息
        Logininfo loginContext = LoginContextUtil.getLoginContext();
        bill.setNickName(loginContext.getUsername());
        bill.setUser_id(loginContext.getId());
        //业务类型  宠物购买和支付
        bill.setBusinessType(businessType);
        bill.setCreateTime(new Date());
        bill.setDigest(title);
        bill.setMoney(money);
        //支付方式
        bill.setPayChannel(payChannel);
        //宠物店铺
        bill.setShop_id(shopId);
        bill.setShopName(shopName);
        //支付状态  0待支付 1 已支付  3未付款交易超时关闭，
        bill.setState(PayBill.SATET_WAIT_PAY);
        bill.setUnionPaySn(payNo);
        // 保存
        add(bill);

    }

}
